<template>
  <div class="like-page">
    <van-nav-bar title="我的喜欢" fixed />
     <van-list
  v-model="loading"
  :finished="finished"
  finished-text="没有更多了"
  @load="onLoad"
>
 <ArticleItem v-for="item in list" :key="item.id" :item="item"></ArticleItem>
</van-list>
  </div>
</template>

<script>
import { getLikeList } from '@/api/article.js'
export default {
  name: 'like-page',
  data () {
    return {
      page: 1,
      pageSize: 10,
      list: [],
      loading: false,
      finished: false
    }
  },
  methods: {
    async onLoad () {
      const data = await getLikeList({ page: this.page, pageSize: this.pageSize })
      console.log(data)
      this.list.push(...data.data.rows)
      this.page++
      this.loading = false
      // (4)页码++
      // (5)当所有数据加载完毕,设置finished为true
      // 告诉list组件,所有数据都加载完毕了,此时划到最底部不需要再出发onLoad事件的
      if (data.data.rows.length === 0) {
        this.finished = true
      }
    }
  }
}
</script>

<style lang="less" scoped>
.like-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
